﻿using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;

using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;

namespace RelaysTestApp
{
    public partial class Program
    {
        GTM.Seeed.Relays relays = new GTM.Seeed.Relays(11);
        GT.Timer timer = new GT.Timer(1000);

        void ProgramStarted()
        {
            /******************************************************************************************
            Access modules defined in the designer by typing their name:                            
            
            e.g.  button
                  camera1

            Initialize event handlers here.
            e.g. button.ButtonPressed += new GTM.MSR.Button.ButtonEventHandler(button_ButtonPressed);             
            ***************************************************************************************** */
            timer.Tick += new GT.Timer.TickEventHandler(timer_Tick);
            timer.Start();
            // Do one-time tasks here
            Debug.Print("Program Started");
        }

        bool toggle = true;

        void timer_Tick(GT.Timer timer)
        {
            Debug.Print("Relays on: " + toggle.ToString());
            relays.Relay1 = toggle;
            relays.Relay2 = toggle;
            relays.Relay3 = toggle;
            relays.Relay4 = toggle;

            toggle = !toggle;
        }
    }
}
